package com.eims.ball.info.adapter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import bls.juejin.cn.R;

public class FanxiZhenRongGuesShowAdapter extends BaseAdapter {
	private Context context;




	private String allPlayerB;
	private String[] allPlayes;


		public FanxiZhenRongGuesShowAdapter(Context context,String allPlayerB) {
			super();
			this.context = context;
			this.allPlayerB=allPlayerB;
			if (allPlayerB!=null&&!allPlayerB.equals("")) {
				allPlayes=allPlayerB.split(",");
			}
		
		}

		@Override
		public int getCount() {
		if (allPlayes!=null) {
			return allPlayes.length;
		}

			return 0;
		}

	@Override
	public Object getItem(int position) {

		return position;
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(final int position, View view, ViewGroup parent) {
		ViewHolder holder;
		// 判断View是否为空
		if (view == null) {
			holder = new ViewHolder();

		
			view = LayoutInflater.from(context).inflate(R.layout.fenxi_zhengrong_listview_item, null);
			
			holder.tv_num=(TextView) view.findViewById(R.id.tv_num);
			holder.tv_name=(TextView) view.findViewById(R.id.tv_name);
			holder.tv_show_num=(TextView) view.findViewById(R.id.tv_show_num);
			holder.tv_jinqiu=(TextView) view.findViewById(R.id.tv_jinqiu);
			holder.tv_zhugong=(TextView) view.findViewById(R.id.tv_zhugong);
			holder.tv_huangpai=(TextView) view.findViewById(R.id.tv_huangpai);
			holder.tv_hongpai=(TextView) view.findViewById(R.id.tv_hongpai);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}

		final String[] data=allPlayes[position].split("-");
		if (data[0].equals("")) {
			holder.tv_num.setText("*");	
		}else {
			holder.tv_num.setText(data[0]);	
		}
		
		holder.tv_name.setText(data[1]);	
		holder.tv_show_num.setText(data[2]);	
		holder.tv_jinqiu.setText(data[3]);	
		holder.tv_zhugong.setText(data[4]);	
		holder.tv_huangpai.setText(data[5]);	
		holder.tv_hongpai.setText(data[6]);
		
		return view;
	}

	public boolean isMobileNO(String mobiles) {
		Pattern p = Pattern.compile("1[0-9]{10}");
		Matcher m = p.matcher(mobiles);
		return m.matches();
	}


	static class ViewHolder {
		TextView tv_num,tv_name,tv_show_num,tv_jinqiu,tv_zhugong,tv_huangpai,tv_hongpai;
	}

	

	public String formateRate(String rateStr) {
		if (rateStr.indexOf(".") != -1) {
			
			int num = 0;
			num = rateStr.indexOf(".");

			
			String dianAfter = rateStr.substring(0, num + 1);
			String afterData = rateStr.replace(dianAfter, "");
			if (afterData.length() < 2) {
				afterData = afterData + "0";
			} else {
				afterData = afterData;
			}
			return rateStr.substring(0, num) + "." + afterData.substring(0, 2);
		} else {
			if (rateStr == "1") {
				return "100";
			} else {
				return rateStr;
			}
		}
	}

}
